package com.bjh.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(ZkPropertiesSource.class)
/**
 * 存在配置 weather.enable 并且它的值要是 enable,这个配置类才有效
 */
@ConditionalOnProperty(name = "weather.enable",havingValue = "enable")
public class StarterAutoConfiguration {


    @Autowired
    private ZkPropertiesSource zkPropertiesSource;


   @Bean
   @ConditionalOnMissingBean(ZkConfig.class)
   public ZkConfig zkSourceService () {
       return new ZkConfig(zkPropertiesSource);
   }
}
